let ajaxTime = 0;

export const request = (params) => {
    ajaxTime++;
    //显示加载中的效果
    wx.showLoading({
        title: "加载中",
        mask: true,
    });
    //定义公共的url
    // const baseUrl = "https://www.fastmock.site/mock/1c3b14715feef12ca0b201429ce14b2a/shopmall"
    return new Promise((resolve, reject) => {
        wx.request({
            ...params,
            // url:baseUrl+params.url,
            success:(res) =>{
                resolve(res);
            },
            fail: (err) => {
                reject(err);
            },
            complete:()=>{
                //关闭正在等待图标
                ajaxTime--;
                wx.hideLoading();
            }
        })
    })
}